package Twice.day07.singleton;

/**
 * @Author: lya
 * @Description: 本类的作用描述:懒汉模式
 * @CreateDate: 2019/8/31
 * @Version: 1.0
 */
public class LazyMyDataSource {
    //定义一个本类的唯一实例
    private static LazyMyDataSource instance = null;

    //私有化构造
    private LazyMyDataSource(){
        System.out.println("实例化.....");
    }

    //定义一个公开的静态的方法返回这个实例
    public static synchronized LazyMyDataSource getInstance(){
        //如果有则返回没有就创建
        return instance == null ? instance = new LazyMyDataSource():instance;
    }
}
